import torch
from perceptron_model import PerceptronModel
from net_model import MultiLayerPerceptronModel

# 加载单层感知机模型参数
model1 = PerceptronModel(1, 1)
model1.load_state_dict(torch.load('perceptron_model.pth'))
# 加载多层感知机模型参数
model2 = MultiLayerPerceptronModel(1, 2, 1)
model2.load_state_dict(torch.load('net_model.pth'))

# 推理
test_input = torch.tensor([10.0])
test_output = model1(test_input.unsqueeze(0))
print("perceptron model structure:")
print(model1)
print(f"Test input: 10.0, Test output: {test_output.item():.4f}")

# 推理 
test_output = model2(test_input.unsqueeze(0))
print("\nnet model structure:")
print(model2)
print(f"Test input: 10.0, Test output: {test_output.item():.4f}")



